package com.ly.talent.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.talent.domain.TalentUniversity;
import com.ly.talent.service.ITalentUniversityService;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.common.core.page.TableDataInfo;

/**
 * 学校信息Controller
 * 
 * @author sfli
 * @date 2021-03-02
 */
@RestController
@RequestMapping("/talent/talentUniversity")
public class TalentUniversityController extends BaseController
{
    @Autowired
    private ITalentUniversityService talentUniversityService;

    /**
     * 查询学校信息列表
     */
    @PreAuthorize("@ss.hasPermi('talent:talentUniversity:list')")
    @GetMapping("/list")
    public TableDataInfo list(TalentUniversity talentUniversity)
    {
        startPage();
        List<TalentUniversity> list = talentUniversityService.selectTalentUniversityList(talentUniversity);
        return getDataTable(list);
    }

    /**
     * 导出学校信息列表
     */
    @PreAuthorize("@ss.hasPermi('talent:talentUniversity:export')")
    @Log(title = "学校信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TalentUniversity talentUniversity)
    {
        List<TalentUniversity> list = talentUniversityService.selectTalentUniversityList(talentUniversity);
        ExcelUtil<TalentUniversity> util = new ExcelUtil<TalentUniversity>(TalentUniversity.class);
        return util.exportExcel(list, "talentUniversity");
    }

    /**
     * 获取学校信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('talent:talentUniversity:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(talentUniversityService.selectTalentUniversityById(id));
    }

    /**
     * 新增学校信息
     */
    @PreAuthorize("@ss.hasPermi('talent:talentUniversity:add')")
    @Log(title = "学校信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TalentUniversity talentUniversity)
    {
        return toAjax(talentUniversityService.insertTalentUniversity(talentUniversity));
    }

    /**
     * 修改学校信息
     */
    @PreAuthorize("@ss.hasPermi('talent:talentUniversity:edit')")
    @Log(title = "学校信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TalentUniversity talentUniversity)
    {
        return toAjax(talentUniversityService.updateTalentUniversity(talentUniversity));
    }

    /**
     * 删除学校信息
     */
    @PreAuthorize("@ss.hasPermi('talent:talentUniversity:remove')")
    @Log(title = "学校信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(talentUniversityService.deleteTalentUniversityByIds(ids));
    }
}
